package meta.api.web.operation.businesscontrol;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import meta.api.web.account.business.UserMngService;
import meta.api.web.account.businessinfo.UserInfo;
import meta.api.web.operation.business.OpnMngService;
import meta.api.web.operation.businessinfo.ValueInfo;

@Transactional
@Component
public class OpnMngBusiCtrl {

    @Autowired
    private OpnMngService opnMngService;

    @Autowired
    private UserMngService userMngService;

    @Transactional(readOnly = true)
    public boolean checkExistAccount(String account) {
        return userMngService.checkExistAccount(account);
    }

    @Transactional(readOnly = true)
    public boolean checkExistAccountId(String id) {
        return userMngService.checkExistAccountId(id);
    }

    @Transactional(readOnly = true)
    public boolean checkAccountUsedByOther(String id, String account) {
        return userMngService.checkAccountUsedByOther(id, account);
    }

    @Transactional(readOnly = true)
    public int getUserTotal(String query) {
        return userMngService.getUserTotal(query);
    }

    @Transactional(readOnly = true)
    public List<UserInfo> getUserList(String query, Integer current, Integer pageSize) {
        return userMngService.getUserList(query, current, pageSize);
    }

    @Transactional(rollbackFor = Exception.class)
    public void addUser(UserInfo inputUser) {
        userMngService.registerUser(inputUser);
    }

    @Transactional(readOnly = true)
    public UserInfo getUser(String account, boolean pswdFlg) {
        return userMngService.getUser(account, pswdFlg);
    }

    @Transactional(rollbackFor = Exception.class)
    public void updateUser(UserInfo user) {
        userMngService.updateUser(user);
    }

    @Transactional(rollbackFor = Exception.class)
    public void deleteUser(String id) {
        userMngService.deleteUser(id);
    }

    @Transactional(readOnly = true)
    public int getValueTotal(String type, String queryForKey) {
        return opnMngService.getValueTotal(type, queryForKey);
    }

    @Transactional(readOnly = true)
    public List<Object> getValueList(String type, String queryForKey, Integer current, Integer pageSize) {
        return opnMngService.getValueList(type, queryForKey, current, pageSize);
    }

    @Transactional(rollbackFor = Exception.class)
    public void saveValue(ValueInfo value) {
        opnMngService.saveValue(value);
    }

    @Transactional(rollbackFor = Exception.class)
    public void deleteValue(ValueInfo value) {
        opnMngService.deleteValue(value);
    }
}
